package com.qf.controller;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    // *代表的是所有的域名都可以访问
    @CrossOrigin("*") // 添加这个注解其实就是给响应头中设置一个Access-Control-Allow-Origin
    @RequestMapping("/server2")
    public String server1(String callback){
        System.out.println(callback);
        System.out.println("HelloController.server2");
        String str = "server2";
        return callback+"('"+str+"')";
    }

    @RequestMapping("/server3")
    public String server3(String callback){ // callback实际就是hello
        String str = "这是JSONP";
        return callback+"('"+str+"')"; // hello('这是JSONP')
    }
}
